package com.eunion.core.common.jpa.deletgate;

import java.io.Serializable;

import javax.persistence.metamodel.SingularAttribute;

import org.springframework.data.jpa.repository.support.JpaEntityInformation;
import org.springframework.util.Assert;

public class ProjectionJpaEntityInformation<Entity, Bean, ID extends Serializable>
        implements JpaEntityInformation<Entity, ID> {

    private Class<Bean> beanClass;

    private JpaEntityInformation<Entity, ID> delegate;

    public ProjectionJpaEntityInformation(JpaEntityInformation<Entity, ID> delegate) {
        Assert.notNull(delegate, "Delegated object must not be null!");
        this.delegate = delegate;
    }

    public Class<Bean> getBeanClass() {
        return beanClass;
    }

    public void setBeanClass(Class<Bean> beanClass) {
        this.beanClass = beanClass;
    }

    public Class<Entity> getJavaType() {
        return delegate.getJavaType();
    }

    public String getEntityName() {
        return delegate.getEntityName();
    }

    public boolean isNew(Entity entity) {
        return delegate.isNew(entity);
    }

    public ID getId(Entity entity) {
        return delegate.getId(entity);
    }

    public SingularAttribute<? super Entity, ?> getIdAttribute() {
        return delegate.getIdAttribute();
    }

    public Class<ID> getIdType() {
        return delegate.getIdType();
    }

    public boolean hasCompositeId() {
        return delegate.hasCompositeId();
    }

    public Iterable<String> getIdAttributeNames() {
        return delegate.getIdAttributeNames();
    }

    public Object getCompositeIdAttributeValue(Serializable id, String idAttribute) {
        return delegate.getCompositeIdAttributeValue(id, idAttribute);
    }

}
